﻿<UserControl
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
	xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
	xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:Interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
    xmlns:Mvvm="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras.WP7"    
	mc:Ignorable="d"
	x:Class="Tfs.OnTheRoad.Controls.ChangesetsListControl"
	d:DesignWidth="480" d:DesignHeight="800" x:Name="ChangesetsListControlPage">
    <Grid Margin="10,0,10,0" x:Name="changesetsGrid">
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="Auto"/>
        </Grid.RowDefinitions>
        <ListBox toolkit:TiltEffect.IsTiltEnabled="True"  x:Name="ChangesetsListBox" Grid.Row="0" ItemsSource="{Binding Items}" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}}">
            <Interactivity:Interaction.Triggers>
                <Interactivity:EventTrigger EventName="SelectionChanged">
                    <Mvvm:EventToCommand Command="{Binding NavigateToChangeset}" PassEventArgsToCommand="True">
                    </Mvvm:EventToCommand>
                </Interactivity:EventTrigger>
            </Interactivity:Interaction.Triggers>
            <ListBox.Template>
                <ControlTemplate TargetType="ListBox">
                    <ScrollViewer>
                        <StackPanel>
                            <ItemsPresenter/>
                            <HyperlinkButton Content="Load More ..." Margin="10" HorizontalAlignment="Center" VerticalAlignment="Center" Visibility="{Binding LoadMoreResultsVisible, Converter={StaticResource BooleanToVisibilityConverter}}" Style="{StaticResource HyperlinkButtonNotUnderlineStyle}" >
                                <Interactivity:Interaction.Triggers>
                                    <Interactivity:EventTrigger EventName="Click">
                                        <Mvvm:EventToCommand Command="{Binding LoadMoreItems}"></Mvvm:EventToCommand>
                                    </Interactivity:EventTrigger>
                                </Interactivity:Interaction.Triggers>
                            </HyperlinkButton>
                        </StackPanel>
                    </ScrollViewer>
                </ControlTemplate>
            </ListBox.Template>
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <StackPanel Margin="0,0,0,17">
                        <TextBlock Text="{Binding Comment}" TextWrapping="Wrap" Style="{StaticResource PhoneTextTitle3StyleWithoutForeground}"/>
                        <StackPanel Orientation="Horizontal">
                            <TextBlock Text="Id - " TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBlock Text="{Binding Id}" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextSubtleStyle}"/>
                            <TextBlock Text=" - " TextWrapping="Wrap" Style="{StaticResource PhoneTextSubtleStyle}" />
                            <TextBlock Text="{Binding CreationDate}" Foreground="{StaticResource PhoneAccentBrush}" Style="{StaticResource PhoneTextSubtleStyle}"/>
                        </StackPanel>
                        <StackPanel Orientation="Horizontal">
                            <Image Grid.Column="0" Width="24" HorizontalAlignment="Right" Source="/Images/ChangesetUser.png" VerticalAlignment="Center"></Image>
                            <TextBlock Text="{Binding Committer}" Style="{StaticResource PhoneTextSubtleStyle}" />
                        </StackPanel>
                    </StackPanel>
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>
        <TextBlock Grid.Row="0" Visibility="{Binding HasResults, Converter={StaticResource BooleanToVisibilityConverter}, ConverterParameter=true}" Padding="10" TextWrapping="Wrap" FontSize="30" Text="{Binding NoResultsFoundMessage}"></TextBlock>
        <StackPanel Visibility="{Binding ElementName=ChangesetsListControlPage, Path=ProgressBarVisibility}">
            <toolkit:PerformanceProgressBar Height="20" x:Name="SearchProgressBar" Grid.Row="1" IsIndeterminate="True" Visibility="{Binding IsSearching, Converter={StaticResource BooleanToVisibilityConverter}}" />
        </StackPanel>
    </Grid>
</UserControl>